//package com.moli.iov.task.service.impl;
//
//import com.moli.iov.base.remote.IVehicleBaseRemoteService;
//import com.moli.iov.base.remote.IVehicleTboxRemoteService;
//import com.moli.iov.his.model.po.ReportTotalOnline;
////import com.moli.iov.his.service.IReportSelledOnlineService;
//import com.moli.iov.his.remote.IHisStatRemoteService;
//import com.moli.iov.his.service.IReportTotalOnlineService;
//import com.moli.iov.rest.RestResponse;
//import com.moli.iov.task.service.IVehicleStatisticsService;
//import com.moli.iov.util.DateUtil;
//import com.xxl.job.core.log.XxlJobLogger;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import javax.annotation.Resource;
//import java.math.BigDecimal;
//import java.math.RoundingMode;
//import java.util.ArrayList;
//import java.util.Date;
//import java.util.List;
//
///**
// * @author fudh
// * @ClassNmme VehicleStatisticsService
// * @date 2019/2/19 13:27
// * @Description: TODO
// */
//@Slf4j
//@Service("vehicleStatisticsService")
//public class VehicleStatisticsService implements IVehicleStatisticsService {
//
//    @Resource
//    private IVehicleTboxRemoteService vehicleTboxRemoteService;
//
//    @Autowired
//    private IHisStatRemoteService hisStatRemoteService;
//
//    @Autowired
//    public IVehicleBaseRemoteService vehicleBaseRemoteService;
//
////
////    @Autowired
////    private IReportSelledOnlineService reportSelledOnlineService;
//
//    @Override
//    public boolean vehicleOnlineStatistics(List<String> vinOnLins) {
//        if (vinOnLins == null ) {
//            return false;
//        }
//        try {
//            List<String> totalvinList = new ArrayList<>();//总的车辆集合
//            RestResponse restResponse = null;
//            long totalVinCount;
//            try {
//                restResponse = vehicleTboxRemoteService.queryVehicleTboxCount();
//                if (restResponse != null && restResponse.getCode() == 0) {
//                    totalVinCount = (long) restResponse.getData();
//                } else {
//                    XxlJobLogger.log("查询在网的vin总数失败");
//                    log.error("查询在网的vin总数失败");
//                    totalVinCount = 0;
//                }
//            } catch (Exception e) {
//                XxlJobLogger.log("查询在网的vin总数失败");
//                log.error(e.getMessage(), e);
//                totalVinCount = 0;
//            }
//            long onlineVehicleCount = vinOnLins.size();
//            XxlJobLogger.log("在线车辆数：" + onlineVehicleCount + "\t在网总数：" + totalVinCount);
//            BigDecimal onLineRate;
//            if (totalVinCount == 0 || onlineVehicleCount == 0) {
//                onLineRate = BigDecimal.valueOf(0);
//            } else {
//                BigDecimal decimal = BigDecimal.valueOf(onlineVehicleCount * 100);
//                BigDecimal decimal1 = BigDecimal.valueOf(totalVinCount);
//                //3、计算昨天的在线率
//                onLineRate = decimal.divide(decimal1, 1, RoundingMode.HALF_UP);
//            }
//            XxlJobLogger.log("在网车辆上线率:" + onLineRate.doubleValue());
//            //4、入库在网数据
//            ReportTotalOnline reportTotalOnline = new ReportTotalOnline(totalVinCount, onlineVehicleCount, onLineRate);
//            reportTotalOnline.setStatTime(DateUtil.subDay(new Date(), 1));
//            reportTotalOnlineService.saveReportTotalOnline(reportTotalOnline);
//            return true;
//        } catch (Exception e) {
//            log.error(e.getMessage(),e);
//            XxlJobLogger.log("统计在网车辆上线率出错！");
//            return false;
//        }
//
//    }
//
//
//}
